<template>
  <div class="withdraw">
    <!-- 头部 -->
    <div class="withdraw_top">
      可提现金额：¥{{all_money}}
    </div>
    <!-- 提现金额 -->
 
  <div class="main">
    
    <div class="withdraw_sum flex">
      <p class="withdraw_sum_tit">提现金额</p>
      <p class="withdraw_sum_subtit">¥</p>
      <input class="withdraw_sum_ipt"  v-model="take_money">
    </div>

    <div class="caretext">* 提现收取提现金额6%手续费</div>

  </div>

   
   
    <!-- 支付方式 -->
    <div class="withdraw_pay">
      <p class="withdraw_pay_tit">支付方式</p>
      <div class="withdraw_main">
        <div class="withdraw_list flex">
          <label for="alipay">提现到支付宝</label>
          <input type="radio" id="alipay" value="Alipay" v-model="check">
        </div>
        <ul class="withdraw_list_cont" v-show="check == 'Alipay'">
          <li class="flex"> 
            <div class="withdraw_list_l">
              姓名
            </div>
            <div class="withdraw_list_r">
              <input v-model="user_name">
            </div>
          </li>
          <li class="flex">
            <div class="withdraw_list_l">
              支付宝账号
            </div>
            <div class="withdraw_list_r">
              <input v-model="user_alipay">
            </div>
          </li>
        </ul>
        <div class="withdraw_list flex">
          <label for="bank">提现到银行卡</label>
          <input type="radio" id="bank" value="Bank" v-model="check">
        </div>
        <ul class="withdraw_list_cont" v-show="check == 'Bank'">
          <li class="flex">
            <div class="withdraw_list_l">
              姓名
            </div>
            <div class="withdraw_list_r">
              <input v-model="user_name">
            </div>
          </li>
          <li class="flex">
            <div class="withdraw_list_l">
              银行
            </div>
            <div class="withdraw_list_r">
              <input v-model="user_bank_name">
            </div>
          </li>
          <li class="flex">
            <div class="withdraw_list_l">
              卡号
            </div>
            <div class="withdraw_list_r">
              <input v-model="user_bank_number">
            </div>
          </li>
        </ul>
      </div>
    </div>
    <!-- 提现须知 -->
    <div class="withdraw_info flex">
      <input type="checkbox" id="checkbox" v-model="info">
      <label for="checkbox">我已阅读并同意</label>
      <span @click="toDrawNotice">《提现须知》</span>
    </div>
    <!-- <button v-bind:class="[info == true ? 'withdraw_btn' : 'withdraw_btn withdraw_btn_no']">提现</button> -->
    <button class="withdraw_btn" @click="Tixian" v-if="info == true">提现</button>
    <button class="withdraw_btn_no" disabled="disabled" v-else>提现</button>
    <!-- 更新经纬度 -->
    <lat-lng></lat-lng>
  </div>
</template>




<script>

import global from '../../../utils/global'
import axios from 'axios'
import store from '../../../utils/store'

export default {

  name: 'withdraw',
  data () {
    return {
      all_money: 10,
      take_money: 0,
      check: '',
      info: '',
      user_name: '',
      user_alipay: '',
      user_bank_name: '',
      user_bank_number: '',
    }
  },
  mounted() {

    console.log('==++++++++++++++++='+global.order.worker.wallet)
    this.all_money = global.order.worker.wallet;

    this.$root.washShare();
  },
  
  methods: {
    
    
    Tixian(){
      console.log('提现');
      var that = this;
      var type = 0;
      
      if(that.take_money == 0){
        alert('请输入提现金额')
      }
      if(that.take_money > that.all_money){
        alert('提现金额不足')
      }
      
      if(!that.user_name.length){
        alert('请填写姓名')
      }
      if(!that.check.length){
        alert('请选择提现方式')
      }else{
        that.check == 'Alipay' ? type = 1 : type = 2
      }


      axios.post(global.api.order.worker.Tixian,{
        uuid: localStorage.getItem('carWashUuid'),
        money: that.take_money,
        type:  type,
        ali_number: that.user_alipay,
        bank_number: that.user_bank_number,
        bank_name: that.user_bank_name,
        name: that.user_name
    
      })
      .then(function(res){
        console.log("confirmAfter then");
        console.log('提现返回值'+res);
        if (res.data.code == 0) {

          alert('提现成功')

          that.$router.push({path:'/washuser'})
        }
      })
      .catch(function(res){
        
      }) 
    },


    toDrawNotice(){
      // alert("提现须知");
      this.$router.push({path:'/washDrawNotice'})
    },
  }
}
</script>




<style scoped>
  .withdraw{}
  /* 头部 */
  .withdraw_top{
    background-color: #E4E4E5;
    line-height: 2.5rem;
    padding: 0 1rem 0 1.5rem;
    text-align: left;
    font-size: 0.9rem;
  }
  
  .main{
    padding: 1.8rem 0 1rem;
    border-bottom: 1px solid #B3B3B4;
    box-shadow: 0 0.6rem 0 0 #E5E5E6;
    margin-bottom: 0.6rem;
  }
  .caretext{
    color: #888888;font-size: 0.85rem;
    text-align: left;
    margin-left: 1.2rem;
    margin-top: 0.8rem;
  }

  /* 提现金额 */
  .withdraw_sum{
    justify-content: flex-start;
    /*align-items: center;*/
    color: #2ecc80;
    
  }
  .withdraw_sum_tit{
    font-size: 1rem;
    padding: 0 1.2rem 0 1.5rem;
  }
  .withdraw_sum_subtit{
    font-size: 1.4rem;
    padding-right: 0.5rem;
  }
  .withdraw_sum_ipt{
    border: 1px solid #B3B3B4;
    width: 8.75rem;
    height: 1.75rem;
  }
  /* 支付方式 */
  .withdraw_pay{}
  .withdraw_pay_tit{
    font-size: 0.9rem;
    color: #2ecc80;;
    padding: 1rem 0 0 1.5rem;
    text-align: left;
  }
  .withdraw_main{
    box-shadow: 0 0.6rem 0 0 #E5E5E6;
    margin-bottom: 0.6rem;
  }
  .withdraw_list {
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem 0 1.5rem;
    height: 3rem;
    line-height: 3rem;
    border-bottom: 1px solid #B3B3B4;
  }
  .withdraw_list label{
    font-size: 0.9rem;
  }
  .withdraw_list input{

  }
  .withdraw_list_cont{
    border-bottom: 1px solid #B3B3B4;
    padding: 0.8rem 0;
  }
  .withdraw_list_cont li{
    justify-content: flex-start;
    align-items: center;
    height: 2.75rem;
    line-height: 2.75rem;
    text-align: left;
  }
  .withdraw_list_l{
    width: 6rem;
    text-align: right;
    font-size: 0.9rem;
    padding-right: 1rem;
  }
  .withdraw_list_r{
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
  }
  .withdraw_list_r input{
    height: 2rem;
  }
  /*提现*/
  .withdraw_info{
    font-size: 0.85rem;
    color: #888888;
    justify-content: center;
    align-items: center; 
    margin: 3rem 0 1.5rem;
  }
  .withdraw_btn{
    width: 8rem;
    height: 2.5rem;
    line-height: 2.5rem;
    background-color: #2ecc80;
    color: #fff;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
  }
  .withdraw_btn_no{
    width: 8rem;
    height: 2.5rem;
    line-height: 2.5rem;
    background-color: #B6B6B7;
    color: #fff;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
  }
</style>
<style>  
  button:focus,input:focus{
    outline-offset: 0px;
    outline: -webkit-focus-ring-color auto 0px;
  }
  ul,li,div,a,p,span{
    margin: 0;
    padding: 0;
  }
  li{
    list-style: none;
  }
  .flex{
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
  }
  .flex_1{
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
  }
</style>